]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/Actors/Actor.cs
I have the worst commits ever.
[rbdr/super-polarity] / Super Polarity / Actors / Actor.cs
index 588ff1421875dcf45c45055afeed61b3c0eb432f..8c71af080a9c677bb720941d6d7a08af6ba551ba 100644 (file)
@@ -10,7 +10,7 @@ namespace SuperPolarity
 {
     class Actor
     {
-        protected Game game;
+        protected SuperPolarity game;
 
         public List<Actor> Children;
 
@@ -18,6 +18,9 @@ namespace SuperPolarity
         protected Texture2D Texture;
         protected Vector2 Origin;
         public bool Active;
+        public Rectangle Box;
+        protected Vector4 BoxDimensions;
+        protected Texture2D BoxTexture;
 
         // Physical Properties
         public Vector2 Position;
@@ -28,6 +31,13 @@ namespace SuperPolarity
         // Constraints / Behavior
         protected float MaxVelocity;
         protected float AccelerationRate;
+        protected int HP;
+        protected bool Immortal;
+        public bool Dying;
+        public int Value;
+        protected Color Color;
+
+        public Actor Parent;
 
         public int Width
         {
@@ -39,7 +49,7 @@ namespace SuperPolarity
             get { return Texture.Height; }
         }
 
-        public Actor(Game newGame)
+        public Actor(SuperPolarity newGame)
         {
             game = newGame;
         }
@@ -58,6 +68,27 @@ namespace SuperPolarity
 
             MaxVelocity = 5;
             AccelerationRate = 10;
+
+            HP = 1;
+            Immortal = false;
+            BoxDimensions.X = 20;
+            BoxDimensions.Y = 20;
+            BoxDimensions.W = 20;
+            BoxDimensions.Z = 20;
+
+            Dying = false;
+            Value = 1;
+
+            InitBox();
+            BoxTexture = new Texture2D(game.GraphicsDevice, 1, 1);
+            BoxTexture.SetData(new Color[] { Color.White });
+
+            Color = Color.White;
+        }
+
+        protected void InitBox()
+        {
+            Box = new Rectangle((int)(Position.X - BoxDimensions.X), (int)(Position.Y - BoxDimensions.X), (int)(BoxDimensions.X + BoxDimensions.W), (int)(BoxDimensions.Y + BoxDimensions.Z));
         }
 
         public void AutoDeccelerate(GameTime gameTime)
@@ -120,6 +151,13 @@ namespace SuperPolarity
             Move(gameTime);
             ChangeAngle();
             CheckOutliers();
+            UpdateBox();
+        }
+
+        protected virtual void UpdateBox()
+        {
+            Box.X = (int)(Position.X - BoxDimensions.X);
+            Box.Y = (int)(Position.Y - BoxDimensions.Y);
         }
 
         public virtual void Move(GameTime gameTime)
@@ -167,7 +205,8 @@ namespace SuperPolarity
                 child.Draw(spriteBatch);
             }
 
-            spriteBatch.Draw(Texture, Position, null, Color.White, Angle, Origin, 1f, SpriteEffects.None, 0f);
+            spriteBatch.Draw(Texture, Position, null, Color, Angle, Origin, 1f, SpriteEffects.None, 0f);
+            spriteBatch.Draw(BoxTexture, Box, new Color(255, 0, 255, 25));
         }
 
         void CheckOutliers()
@@ -183,5 +222,26 @@ namespace SuperPolarity
                 }
             }
         }
+
+        public virtual void Collide(Actor other, Rectangle collision)
+        {
+        }
+
+        public void TakeDamage(int amount)
+        {
+            if (!Immortal)
+            {
+                HP = HP - amount;
+                if (HP < 0)
+                {
+                    Die();
+                }
+            }
+        }
+
+        protected virtual void Die()
+        {
+            Dying = true;
+        }
     }
 }